<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Good;

class LuckyController extends Controller
{
    public function lucky(Good $good,$id = '3'){
        //分页查询
        if($id == '3'){
            $data = Good::select()->paginate(8);
        }else{
            $data = $good->where('style',$id)->paginate(8);
        }
        //推荐查询
        $tuijian = Good::select()->where('recomm','yes')->paginate(6);
        return view('home/lucky/lucky',['data'=>$data,'tuijian'=>$tuijian]);
    }
    //详情
    public function lucky_list(Good $good,$id){
        $data = $good->where('id',$id)->get();
        return view('home/lucky/lucky_list',['data'=>$data]);
    }
}
